/*
 * Copyright 2025 arisgo@163.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.arisgo.cloud.auth.login.granter.configurer;

import com.arisgo.cloud.common.utils.CipherUtil;
import com.arisgo.cloud.common.utils.StringUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

/**
 * 超级管理员配置
 *
 * @author Arisgo
 * @since 2024/7/8
 */
@Data
@Configuration
@ConfigurationProperties(value = "arisgo.cloud.auth.manager")
public class ManagerConfigurer {
    private Long userId = 0L;
    /**
     * 超级管理员
     */
    private String account = "Coulson";
    private String password = "cloud2024";
    /**
     * 密码默认加密方式
     */
    private String encipher = "SHA";
    private String nickname = "超级管理员";
    /**
     * 超级租户
     */
    private Long tenantId = 0L;
    private String tenantName = "超级租户";
    /**
     * 角色 id
     */
    private Long roleId = 0L;

    public String getPassword() {
        if (!StringUtils.hasLength(password)) {
            password = "cloud2024";
        }
        if (!StringUtil.hasLength(encipher)) {
            encipher = "SHA";
        }
        return CipherUtil.encode(password, encipher);
    }

}
